//
//  AXGoodItemView.m
//  AnXueCloud
//
//  Created by apple on 2020/7/13.
//  Copyright © 2020 imac. All rights reserved.
//

#import "THHomeGoodItemView.h"
@interface THHomeGoodItemView()

@end
@implementation THHomeGoodItemView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self stoneobs_ui_configSubView];
        
    }
    return self;
}
#pragma mark --configSubView
- (void)stoneobs_ui_configSubView{
    __weak typeof(self) weakSelf =  self;
    UITapGestureRecognizer * tap = [UITapGestureRecognizer.alloc initWithActionBlock:^(id  _Nonnull sender) {
        [TMUtils goto_good_detail_witdh_id:weakSelf.model.g_id];
    }];
    [self addGestureRecognizer:tap];
    self.userInteractionEnabled = YES;
    UIImage * image = STFDRandomImageProvider.random_banner_shop_image;
    self.icon_imageView = UIImageView.new;
    self.icon_imageView.image = image;
    [self addSubview:self.icon_imageView];
    self.icon_imageView.contentMode = UIViewContentModeScaleAspectFill;
    self.icon_imageView.clipsToBounds = YES;
    
    ({
        STLabel * stoneobs_ui_label = [[STLabel alloc] initWithFrame:CGRectMake(0, 0, 200, 20)
                                                                text:@" 商品名称商品名称商品名 称商品名称商品名称 "
                                                           textColor:STONEOBS_UI_FIRST_TEXT_COLOR
                                                                font:13
                                                         isSizetoFit:NO
                                                       textAlignment:NSTextAlignmentLeft];
        [self addSubview:stoneobs_ui_label];
        self.nameLable = stoneobs_ui_label;
    });

    ({
        STLabel * stoneobs_ui_label = [[STLabel alloc] initWithFrame:CGRectMake(0, 0, 200, 20)
                                                                text:@"￥699"
                                                           textColor:FlatRed
                                                                font:13
                                                         isSizetoFit:NO
                                                       textAlignment:NSTextAlignmentLeft];
        [self addSubview:stoneobs_ui_label];
        self.priceLable = stoneobs_ui_label;

    });
    
}
- (void)layoutSubviews{
    self.icon_imageView.frame = CGRectMake(0, 0, self.width, self.height - 60);
    
    self.nameLable.top = self.icon_imageView.bottom + 5;
    self.nameLable.width = self.width;
    
    self.priceLable.top = self.nameLable.bottom + 5;
    self.priceLable.width = self.width;
}
- (void)setModel:(THGoodModel *)model{
    _model = model;
    [self.icon_imageView sd_setImageWithURL:model.img.mj_url];
    self.nameLable.text = model.name;
    self.priceLable.text = [NSString stringWithFormat:@"￥%@",model.price];
}
@end
